<table border="0" cellspacing="0" cellpadding="0" class="t1">
  <td align="right"><div class="div_msg">{$message}</div></td>
   <td align="left"><div class="div_msg">{$flag}</div></td>
  <td class="buttom"><a class="bule" href="__URL__/add"></a></td>
  </tr>
</table>
<div id="nav" class="mainnav_title">
    <ul>
        <a class="on" href="{:U('lists')}">单页列表</a> |
        <a href="{:U('add')}">添加页面</a>
    </ul>
</div>
<form name="myform" id="myform" action="" method="post">
    <div class="table-list">
        <table cellspacing="0" cellpadding="0" width="100%">

            <thead>
            <tr>
                <th width="62"><a href="javascript:void(0);" onclick="sel_all();">全选</a></th>
                <th width="220">标题</th>
                <th>所属栏目</th>
                <th>添加日期</th>
                <th>点击数</th>
                <th>排序</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <volist name="list" id="vo" key="i">
                <tr class="ulbc" id="tr_{$vo.id}">
                    <td id="td_sel" align="center"><input type="checkbox" class="sel" id="sel_{$vo.id}" value="{$vo.id}" name="items_{$vo.id}" /></td>
                    <td align="center"><input type="text" name="sort[{$vo.id}]" id="title_{$vo.id}" size="26" value="{$vo.title}"/></td>
                    <td style="text-align: center;">{$section[$i-1].names}</td>
                    <td align="center">{$vo.add_time|date="Y-m-d H:i:s",###}</td>
                    <td align="center">{$vo.hits}</td>
                    <td align="center"><input type="text" size="9" name="sort[{$vo.id}]" id="sort_{$vo.id}" value="{$vo.sort}"/></td>
                    <td align="center">
                        <a href="javascript:void(0);" onclick="ajax_save('{$vo.id}')">保存</a>&nbsp;<a href="__URL__/edit?id={$vo.id}">编辑</a>&nbsp;<a href="#" onclick="javascript:if(confirm( '确定要删除该条记录吗？ '))ajax_del({$vo.id});">删除</a>
                    </td>
                </tr>
            </volist>
            </tbody>
        </table>
  </div>
    <div class="btn">
        <input type="submit" class="button" name="dosubmit" value="删除" onclick="myform.action='{:U('deleteall')}';"/>
        <!-- input type="button" class="button" name="dosubmit" value="删除" onclick="myform.action='{:U('deleteall')}';return confirm_deleteall() / -->
        <input type="button" class="button" name="dosubmit" value="排序"
               onclick="myform.action='{:U('sort_list')}';$('#myform').submit();"/>
    </div>
</form>

<script language="javascript">
    function ajax_save(id){
        var url = "{:U(ajax_save)}?id="+id;
        var names = $('#title_'+id).val(); 
		var _sort = $('#sort_'+id).val();
        $.ajax({
            url: url,
            type: "POST",
            complete :function(){
            }, 
            dataType: 'json', 
            data: "id="+ id +"&title="+names+"&sort="+_sort,
            error: function() { alert('Ajax request error');},
            success: function(result){
                if(result==1){
                    art.dialog.alert("保存成功");
                }
				else if(result==0){
					art.dialog.alert("保存失败：文章重名。");
				}
            }
        }); 
    }
    
    function ajax_del(id){
        var url = "{:U(ajax_del)}?id="+id;
		
        $.ajax({
            url: url,
            type: "POST",
            complete :function(){
            }, 
            dataType: 'json', data: "id="+ id,
            error: function() { alert('Ajax request error');},
            success: function(result){
                if(result==1){
					art.dialog({
						title: '删除提示',
						content: '删除成功',
						ok:function(){location.reload();},
					});
					//$("#tr_"+id).remove();
                }
            }
        }); 
    }
	
	function sel_all(){
        $('input.sel').each(function(index){
            if($(this).attr('checked')){
                $(this).removeAttr('checked');
            }else{
                $(this).attr('checked', 'checked');
            }
        });
    }
</script>
<div class="page">{$page}</div>